/**
 * Created by Administrator on 2017/4/13.
 */
import * as types from './type';
import { lsWrite, lsRead } from '../common/js/ls';
export default {
  [types.LOGIN]: (state, data) => {
    state.user = data;
    lsWrite('user', data);
  },
  [types.LOGOUT]: state => {
    state.user = {};
  },
  [types.CREATEROUTES]: (state, data) => {
    state.routes = data;
  },
  [types.SETTHEME]: (state, data) => {
    console.log('vuex data', data);
    localStorage.setItem('theme', data.value); // 缓存起来，刷新的时候重新取用
    if (state.hasOwnProperty(data.key)) {
      state[data.key] = data.value;
    }
  },
};
